home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_12_06 / saks / intq1.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-08  |  668 b   |  46 lines

  1. Listing 1 - class definitions for a queue of int using a non-nested cell 
  2. type
  3.  
  4. //
  5. // intq1.h - a queue of int (interface)
  6. //
  7.  
  8. #include <iostream.h>
  9.  
  10. class intq_cell
  11.     {
  12.     friend class intq;
  13. private:
  14.     intq_cell(const int &e, intq_cell *p);
  15.     intq_cell *next;
  16.     int element;
  17.     };
  18.  
  19. inline intq_cell::intq_cell(const int &e, intq_cell *p)
  20.     : element(e), next(p)
  21.     {
  22.     }
  23.  
  24. class intq
  25.     {
  26. public:
  27.     intq();
  28.     ~intq();
  29.     void append(const int &e);
  30.     void clear();
  31.     void print(ostream &os) const;
  32.     int remove(int &e);
  33. private:
  34.     intq_cell *first, *last;
  35.     };
  36.  
  37. inline intq::intq() : first(0), last(0)
  38.     {
  39.     }
  40.  
  41. inline intq::~intq()
  42.     {
  43.     clear();
  44.     }
  45.  
  46.